﻿@model RoadFlow.Model.AppLibrary
<form id="form1" method="post">
    @Html.AntiForgeryToken()
    <div>
        <div>
            <div style="height:8px;"></div>
            <input type="hidden" name="Id" value="@Model.Id">
            <input type="hidden" name="Code" value="@Model.Code" />
            <table cellpadding="0" cellspacing="1" border="0" width="99%" class="formtable">
                <tr>
                    <th style="width: 80px;">应用名称：</th>
                    <td><input type="text" name="Title" class="mytext" value="@Model.Title" validate="empty" style="width: 75%" /></td>
                </tr>
                <tr>
                    <th>应用地址：</th>
                    <td><textarea class="mytextarea" name="Address" validate="empty" style="width: 75%;height:80px;">@Model.Address</textarea></td>
                </tr>
                <tr>
                    <th>应用分类：</th>
                    <td>
                        <select name="Type" id="Type" class="myselect" validate="empty">
                            <option value=""></option>
                            @Html.Raw(ViewData["typeOptions"])
                        </select>
                        <span style="msg"></span>
                    </td>
                </tr>
                <tr>
                    <th>打开方式：</th>
                    <td>
                        <select name="OpenMode" id="OpenMode" class="myselect" onchange="openModelChange(this.value);">
                            @Html.Raw(ViewData["openModelOptions"])
                        </select>
                    </td>
                </tr>
                <tr id="winsizetr" style="display: none;">
                    <th>窗口大小：</th>
                    <td>
                        宽度：<input type="text" name="Width" class="mytext" value="@Model.Width" validate="int,canempty" style="width: 150px;" />
                        高度：<input type="text" name="Height" class="mytext" value="@Model.Height" validate="int,canempty" style="width: 150px;" />
                    </td>
                </tr>
                <tr>
                    <th>备注说明：</th>
                    <td><textarea class="mytextarea" name="Note" id="Note" cols="1" rows="1" style="width: 95%; height: 50px;">@Model.Note</textarea></td>
                </tr>
            </table>
            <div class="buttondiv">
                <input type="button" value="确定保存" class="mybutton" onclick="saveApp(this);" />
                <input type="button" class="mybutton" value="取消关闭" style="margin-left: 5px;" onclick="closewin();" />
            </div>
        </div>
    </div>
</form>
<script type="text/javascript">
        var win = new RoadUI.Window();
        $(window).load(function () {
            $("#OpenMode").change();
        });
        function openModelChange(value) {
            if ("0" == value) {
                $("#winsizetr").hide();
            }
            else {
                $("#winsizetr").show();
            }
        }
        function closewin() {
            win.close();
            return false;
        }
        function saveApp(but) {
            var f=document.forms[0];
            if(new RoadUI.Validate().validateForm(f)){
                var o = RoadUI.Core.serializeForm($(f));
                $(but).prop("disabled", true);
                $.ajax({url:"Save@(Html.Raw(ViewData["queryString"]))",data:o, type:"post",success:function (text) {
                    if(RoadUI.Core.checkLogin(text, false)) {
                        alert(text);
                    }
                    $(but).prop("disabled",false);
                    win.reloadOpener(undefined, undefined, "query('@ViewData["pageSize"]','@ViewData["pageNumber"]')");
                    win.close();
                }});
            }
        }
</script>